import React, { Component } from 'react';
import './index.less'
let bg = require('../../common/images/login_bg.png');
let profile = require('../../common/images/profile.png');
import {Link} from 'react-router-dom';
import {connect} from 'react-redux';
import * as action from '../../redux/actions/user'
class Profile extends Component {
    componentDidMount(){
        this.props.auth();
    }
    render() { 
        console.log(this.props.user.userInfo.username)
        return (
            <div className="profile">
              <img src={profile}/>
              {this.props.user.userInfo.username?<span>{this.props.user.userInfo.username}</span>:<Link to={'./login'}>登录</Link>}
            </div>
        )
    }
}

export default connect(state=>({...state}),action)(Profile);
